<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>用户注册</title>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>

    <link rel="stylesheet" href="/css/registerbootstrap.min.css">
    <link rel="stylesheet" href="/css/registeranimate.css">
    <link rel="stylesheet" href="/css/registerstyle.css">
    <script>
        function success(msg) {
            pupopTip('200px', '120px', '&nbsp;&nbsp;' + msg);
        }
        function lose(msg) {
            pupopTip('200px', '120px', '&nbsp;&nbsp;' + msg);
        }
    </script>
    <script type="application/javascript">
        function doRegister() {
            var teacher_name = $('#teacherName').val().replace(" ", "");
            var teacher_account = $('#teacherAccount').val().replace(" ", "");
            var teacher_password = $('#teacherPassword').val().replace(" ", "");
            console.log(teacher_name);
            if (teacher_name == null || teacher_name == '' || teacher_account == null || teacher_account == '' || teacher_password == null || teacher_password == '') {
                var msg = "注册信息不允许为空<br>   点击任意位置重新填写";
                lose(msg);
                $(document).bind("click", function (e) {
                    $('div').closest('.pupopBox').each(function () {
                        if (e.target == this) {
                            $(this).remove();
                        }
                    });
                });
            }
            else {
                console.log(teacher_name + teacher_account + teacher_password);
                $.ajax({
                    type: "POST",
                    url: "/registersub",
                    dataType: 'json',
                    data: {
                        'teacherName': teacher_name,
                        'teacherAccount': teacher_account,
                        'teacherPassword': teacher_password
                    },

                    success: function (result) {
                        var msg = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+result.msg + "<br>点击任意位置重新填写";
                        if (result.code == 1 || result.code == '1') {
                            lose(msg);
                            $(document).bind("click", function (e) {
                                $('div').closest('.pupopBox').each(function () {
                                    if (e.target == this) {
                                        $(this).remove();
                                    }
                                });
                            });
                        } else {
                            success(msg);
                            setTimeout(function () {
                                window.location.href = '/login'
                            }, 500);
                        }
                    },
                    error: function (result) {
                        var msg = result.msg;
                        success(msg);
                        setTimeout(function () {
                            window.location.href = '/login'
                        }, 500);
                    }
                })

            }

        }
    </script>

</head>

<body class="style-2">

<div class="container">

    <div class="row">
        <div class="col-md-4">
            <br>
            <h1 class="col-md-12 text-center">快点名系统教师注册</h1>

            <br><br>
            <form action="#" class="fh5co-form animate-box" data-animate-effect="fadeInLeft">
                <h1>Register</h1>
                <br>
                <div class="form-group">
                    <label for="teacherName" class="sr-only">TeacherName</label>
                    <input type="text" class="form-control" id="teacherName" placeholder="请输入教师名称" autocomplete="off">
                </div>
                <div class="form-group">
                    <label for="teacherAccount" class="sr-only">TeacherAccount</label>
                    <input type="text" class="form-control" id="teacherAccount" placeholder="请输入教师账号"
                           autocomplete="off">
                </div>
                <div class="form-group">
                    <label for="teacherPassword" class="sr-only">teacherPassword</label>
                    <input type="password" class="form-control" id="teacherPassword" placeholder="请输入教师密码"
                           autocomplete="off">
                </div>
                <div class="form-group">
                    <input type="submit" value="Register" class="btn btn-primary" onclick="doRegister()">
                </div>
            </form>

        </div>
    </div>
    <div class="row" style="padding-top: 80px; clear: both;">
        <div class="col-md-12 text-center">
            <p>
                <small>&copy; All Rights Reserved. More Templates <a href="" target="_blank" title="快点名系统">快点名系统</a> -
                    Collect from <a href="" title="快点名系统" target="_blank">快点名系统</a></small>
            </p>
        </div>
    </div>
</div>

<script type="text/javascript" src="/js/pupop.js"></script>
<script src="/js/registerjquery.min.js"></script>
<script src="/js/registerbootstrap.min.js"></script>
<script src="/js/registerjquery.placeholder.min.js"></script>
<script src="/js/registerjquery.waypoints.min.js"></script>
<script src="/js/registermain.js"></script>

</body>

</html>